<?php
/*
 * template name: Flight 
 * @author : Tham
 * manage all of flight
 * 
 */
$paginator = new Paginator();
$scroll_page = 3;
$per_page = 8; //5 records/page
$current_page = isset($_GET['pg']) ? ($_GET['pg']) : 1;
$paper_url = '?pg=';
$inactive_page_tag = 'id="current_page"'; //id của thẻ span
$totalRecord = DealFlight::countRecords(DealFlight::FLIGHT);
$next_page_text = '';
$previous_page_text = '';
$first_page_text = '';
$last_page_text = '';

$paginator->page_set($paper_url, $totalRecord[0]->total_design, $scroll_page, $per_page, $current_page, $inactive_page_tag, $next_page_text, $previous_page_text
	, $first_page_text, $last_page_text);


$flights = DealFlight::getAllFight(DealFlight::FLIGHT,$paginator->start,$paginator->per_page);
//print_r($paginator);
get_header();
?>
<div class="content">
    <div class="container">
        <div class=" box-sli">
            <div class="left-slider">
          
          <div class="qoute-box">
          <div class="title-qoute"> II Request a Quote </div>
          <div class="form-qoute">
            <form method="POST" >
              <div class="row01">
                <label>Name</label>
                <input type="text" id="name" name="name" value="<?php if(isset($_REQUEST['name'])){ echo $_REQUEST['name']; } ?>" />
                <span id="error-name" class="error" ></span> </div>
              <div class="row01">
                <label>Email</label>
                <input type="text" id="txt-email" name="txt-email" value="<?php if(isset($_REQUEST['txt-email'])){ echo $_REQUEST['txt-email']; } ?>" />
                <span id="error-email" class="error" ></span> </div>
              <div class="row01">
                <label> Phone number</label>
                <input type="text" id="txt-phone" name="txt-phone" value="<?php if(isset($_REQUEST['txt-phone'])){ echo $_REQUEST['txt-phone']; } ?>" />
                <span id="error-phone" class="error" ></span> </div>
              <div class="class_br"></div>
              <div class="row01">
                <div>
                  <input type="radio" name="typeFlights" id="typeFlights1" value="<?php echo DealFlight::ONEWAY; ?>" />
                  <label class="label-flights">One Way</label>
                  <input type="radio" checked="check" name="typeFlights" id="typeFlights2" value="<?php echo DealFlight::ROUNDTRIP; ?>" />
                  <label class="label-flights" >Round Trip</label>
                  <input type="radio" name="typeFlights" id="typeFlights3" value="<?php echo DealFlight::MULTICITY; ?>" />
                  <label  class="label-flights2" >Multi City</label>
                  <span id="error-type-flight" class="error" ></span> </div>
              </div>
              <div class="class_br"></div>
              <div class="row01">
                <div  id="content_leving">
                  <label>Leaving from</label>
                  <div class="ui-widget">
                    <input  placeholder="Enter City/state" type="text" id="leaving-from" 
						 name="leaving-from" class="txt-state-search"/>
                  </div>
                  <span id="error-leaving-form" class="error" ></span>
                  <div class="class_br"></div>
                  <label> Going to </label>
                  <input type="text" placeholder="Enter City/state"  id="going-to" name="going-to" class="txt-state-search"/>
                  <span id="error-going-to" class="error" ></span>
                  <div class="class_br"></div>
                  <div class="row03">
                    <div class="heading01"> <span id="depart1" style="color: white !important;"> Departure date</span> <span style="color: white!important;" id="return1" > - Return date</span></div>
                    <br/>
                    <input type="text" style="width: 97px;" id="departure-date" name="departure-date" />
                    <img id="image_button" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                    <input type="text" style="width: 96px;" id="return-date" name="return-date" />
                    <img id="image_button2"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time" class="error" ></span> <span id="error-end-time" class="error" ></span> </div>
                </div>
              </div>
              <div  id="content_leving2" style="display: none;">
                <div class="div-boder">
                  <label>Leaving from</label>
                  <input  placeholder="Enter City/state" type="text" id="leaving-from1" 
						name="leaving-from1" class="txt-state-search"/>
                  <span id="error-leaving-form1" class="error" ></span>
                  <div class="class_br"></div>
                  <label> Going to </label>
                  <input type="text" placeholder="Enter City/state"  id="going-to1" name="going-to1" class="txt-state-search"/>
                  <span id="error-going-to1" class="error" ></span>
                  <div class="class_br"></div>
                  <label><span id="depart1" style="color: white !important;"> Departure date</span><span style="color: white !important;" id="return1" > - Return date</span></label>
                  <br/>
                  <input type="text" style="width: 97px;" id="departure-date1" name="departure-date1" />
                  <img id="image_buttona1" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                  <input type="text" style="width: 96px;" id="return-date1" name="return-date1" />
                  <img id="image_buttonb1"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time1" class="error" ></span> <span id="error-end-time1" class="error" ></span>
                  <hr/>
                  <label>Leaving from</label>
                  <input  placeholder="Enter City/state" type="text" id="leaving-from2"
						name="leaving-from2" class="txt-state-search"/>
                  <span id="error-leaving-form2" class="error" ></span>
                  <div class="class_br"></div>
                  <label> Going to </label>
                  <input type="text" placeholder="Enter City/state"  id="going-to2" name="going-to2" class="txt-state-search"/>
                  <span id="error-going-to2" class="error" ></span>
                  <div class="class_br"></div>
                  <label><span id="depart2"> Departure date</span><span style="color: white !important;" id="return1" > - Return date</span></label>
                  <br/>
                  <input type="text" style="width: 97px;" id="departure-date2" name="departure-date2" />
                  <img id="image_buttona2" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                  <input type="text" style="width: 96px;" id="return-date2" name="return-date2" />
                  <img id="image_buttonb2"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time2" class="error" ></span> <span id="error-end-time2" class="error" ></span>
                  </p>
                  <div class="id_tab3">
                    <hr/>
                    <label>Leaving from</label>
                    <input  placeholder="Enter City/state" type="text" id="leaving-from3" 
						    name="leaving-from3" class="txt-state-search"/>
                    <span id="error-leaving-form3" class="error" ></span>
                    </p>
                    <div class="class_br"></div>
                    <label> Going to </label>
                    <input type="text" placeholder="Enter City/state"  id="going-to3" name="going-to3" />
                    <span id="error-going-to3" class="error" ></span>
                    </p>
                    <div class="class_br"></div>
                    <label><span id="depart3" style="color: white !important;"> Departure date</span><span style="color: white !important;" id="return3" > - Return date</span></label>
                    <br/>
                    <input type="text" style="width: 97px;" id="departure-date3" name="departure-date3" />
                    <img id="image_buttona2" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                    <input type="text" style="width: 96px;" id="return-date3" name="return-date3" />
                    <img id="image_buttonb3"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time3" class="error" ></span> <span id="error-end-time3" class="error" ></span>
                    </p>
                  </div>
                  <div class="id_tab4">
                    <hr/>
                    <label>Leaving from</label>
                    <input  placeholder="Enter City/state" type="text" id="leaving-from4"
						    name="leaving-from4" class="txt-state-search"/>
                    <span id="error-leaving-form4" class="error" ></span>
                    <div class="class_br"></div>
                    <label> Going to </label>
                    <input type="text" placeholder="Enter City/state"  id="going-to4" name="going-to4" class="txt-state-search"/>
                    <span id="error-going-to4" class="error" ></span>
                    </p>
                    <div class="class_br"></div>
                    <label><span id="depart4" style="color: white !important;"> Departure date</span><span style="color: white !important;" id="return4" > - Return date</span></label>
                    <br/>
                    <input type="text" style="width: 97px;" id="departure-date4" name="departure-date4" />
                    <img id="image_buttona4" width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> <span id="span-return-date" style="color: #ffffff !important;">-
                    <input type="text" style="width: 96px;" id="return-date4" name="return-date4" />
                    <img id="image_buttonb4"   width="20px;" src="<?php echo get_template_directory_uri(); ?>/images/icon_datetime.png"/> </span> <span id="error-start-time4" class="error" ></span> <span id="error-end-time4" class="error" ></span>
                    </p>
                  </div>
                  <input type="button" value="+ Add more flights"  class="bttngrey" id="addMoreBtnMulti_int" tabindex="20">
                  <input type="hidden" value="2" name="morest" id="morest"  />
                </div>
              </div>
              <div> </div>
              <div class="class_br"></div>
              <div class="personWrapper">
                <div class="row04">
                  <label class="div_type_human">Adult(12+) </label>
                  <select  id="Adult" name="Adult" class="select-find-flights" >
                    <?php
                                                for ($i = 1; $i <= 9; $i++) {
                                                    echo '<option value="' . $i . '" >' . $i . '</option>';
                                                }
                                                ?>
                  </select>
                </div>
                <div class="row04">
                  <label class="div_type_human">Children(2-12)</label>
                  <select  id="numCHD" name="numCHD" class="select-find-flights" >
                    <?php
                                                for ($i = 0; $i < 9; $i++) {
                                                    echo '<option value="' . $i . '" >' . $i . '</option>';
                                                }
                                                ?>
                  </select>
                </div>
                <div class="row04">
                  <label class="div_type_human" > Infant(0-2)</label>
                  <select id="infant"  class="select-find-flights">
                    <option>0</option>
                    <option>1</option>
                  </select>
                </div>
              </div>
              <div class="warappr2">
                <div class="row04">
                  <label  class="div_type_human"> Class </label>
                  <select name="" id="class" class="select-find-flights">
                    <option value="<?php echo DealFlight::ECONOMY; ?>">Economy</option>
                    <option value="<?php echo DealFlight::BUSINESS; ?>">Business</option>
                    <option value="<?PHP echo DealFlight::FIRST_CLASS ?>">First Class</option>
                    <option value="<?php echo DealFlight::PREMIUM_ECONOMY ?>">Premium Economy</option>
                  </select>
                </div>
                <div class="row04">
                  <label  class="div_type_human"> Country </label>
                  <select name="city" id="city" class="select-find-flights country-select" >
                    <?php $countries = Country::listCountry();?>
                    <?php foreach($countries as $key=>$value){
					echo '<option value="'.$key.'">'.$value.'</option>';
					}?>
                  </select>
                </div>
              </div>
              <div class="submitWrapper">
                <input type="button" class="button"  name="tb-search-flights" id="tb-search-flights"  value="Submit" />
              </div>
              <?php
                            //  echo do_shortcode('[contact-form-7 id="44"  title="Request a Quote"]');
                            ?>
            </form>
          </div>
        </div>
          
          
          
          
          
          
            </div><!--col-md-4-->
            <div class="right-slider">
                <div class="right-sli">
                    <?php
                      $dsFightFeature = DealFlight::getFeatureFight();
		      $aImages = unserialize($dsFightFeature[0]->image);
                     // print_r($dsFightFeature);
                    ?>

                    <div class="flight">
			<?php foreach($aImages as $img){?>
			    <img src="<?php echo FLIGHT_URL . $img ?>" />
			<?php 
			    break;
			}?>
                        <div class="title-flight"><?php echo $dsFightFeature[0]->name_deal ?> <span> from £<?php echo $dsFightFeature[0]->price;  ?>+</span></div>
                    </div>
                </div>

            </div><!--col-md-8-->
        </div><!--box-slider-->

        <div class="travel">
            <?php
            foreach ($flights as $fight) {
		 $aImages = unserialize($fight->image);
                ?>
                <li>
		    <?php foreach($aImages as $img){?>
			<img src="<?php echo TIMTHUMB_URL ?>?src=<?php echo FLIGHT_URL . $img ?>&w=227&h=152"/>
		    <?php 
		    break;
		    }?>
                     <div class="travel-titl">
                         <a style="color: white;" href='<?php echo get_site_url(); ?>/flight-detail?i=<?php echo $fight->deal_flight_id; ?>'><?php echo $fight->name_flight; ?></a>
                          <p><?php echo $fight->name ?></p>
                      </div>
                </li>
                <?php
            }
            ?>
         
        </div>
        <br clear="all" />
        <div style="text-align: center;">
        <?php
	echo $paginator->previous_page."         ";
	echo $paginator->next_page;
	?>
        </diV>

    </div><!--container-->
</div><!--content-->
<?php get_footer(); ?>
<script type="text/javascript" lang="javascript">


    jQuery('#image_button').click(function() {
        jQuery('#departure-date').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_button2').click(function() {
        jQuery('#return-date').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date').val() ? jQuery('#return-date').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date').val() ? jQuery('#departure-date').val() : false
                })
            },
            timepicker: false
        });
    });


    jQuery('#image_buttona1').click(function() {
        jQuery('#departure-date1').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb1').click(function() {
        jQuery('#return-date1').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date1').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date1').val() ? jQuery('#return-date1').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date1').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date1').val() ? jQuery('#departure-date1').val() : false
                })
            },
            timepicker: false
        });
    });


    jQuery('#image_buttona2').click(function() {
        jQuery('#departure-date2').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb2').click(function() {
        jQuery('#return-date2').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date2').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date2').val() ? jQuery('#return-date2').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date2').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date2').val() ? jQuery('#departure-date2').val() : false
                })
            },
            timepicker: false
        });
    });
    
    
    
    
     jQuery('#image_buttona3').click(function() {
        jQuery('#departure-date3').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb3').click(function() {
        jQuery('#return-date3').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date3').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date3').val() ? jQuery('#return-date3').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date3').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date3').val() ? jQuery('#departure-date3').val() : false
                })
            },
            timepicker: false
        });
    });
    
     
     jQuery('#image_buttona4').click(function() {
        jQuery('#departure-date4').datetimepicker('show'); //support hide,show and destroy command
    });

    jQuery('#image_buttonb4').click(function() {
        jQuery('#return-date4').datetimepicker('show'); //support hide,show and destroy command
    });


    jQuery(function() {
        jQuery('#departure-date4').datetimepicker({
            format: 'd/m/Y',
            onShow: function(ct) {
                this.setOptions({
                    maxDate: jQuery('#return-date4').val() ? jQuery('#return-date4').val() : false
                })
            },
            timepicker: false
        });
        jQuery('#return-date4').datetimepicker({
            format: 'd/m/M',
            onShow: function(ct) {
                this.setOptions({
                    minDate: jQuery('#departure-date4').val() ? jQuery('#departure-date4').val() : false
                })
            },
            timepicker: false
        });
    });

</script>
